#pragma once

#include "calculationKN.h"

namespace Uravnenie {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	/// </summary>

	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  CalcButton;
	private: System::Windows::Forms::DataVisualization::Charting::Chart^  chart1;
	private: System::Windows::Forms::Button^  PresentationButton;
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::Windows::Forms::DataVisualization::Charting::ChartArea^  chartArea1 = (gcnew System::Windows::Forms::DataVisualization::Charting::ChartArea());
			System::Windows::Forms::DataVisualization::Charting::Legend^  legend1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Legend());
			System::Windows::Forms::DataVisualization::Charting::Series^  series1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
			this->CalcButton = (gcnew System::Windows::Forms::Button());
			this->chart1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Chart());
			this->PresentationButton = (gcnew System::Windows::Forms::Button());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->chart1))->BeginInit();
			this->SuspendLayout();
			// 
			// CalcButton
			// 
			this->CalcButton->Location = System::Drawing::Point(28, 81);
			this->CalcButton->Name = L"CalcButton";
			this->CalcButton->Size = System::Drawing::Size(75, 23);
			this->CalcButton->TabIndex = 0;
			this->CalcButton->Text = L"Calc";
			this->CalcButton->UseVisualStyleBackColor = true;
			this->CalcButton->Click += gcnew System::EventHandler(this, &Form1::CalcButton_Click);
			// 
			// chart1
			// 
			chartArea1->Name = L"ChartArea1";
			this->chart1->ChartAreas->Add(chartArea1);
			legend1->Name = L"Legend1";
			this->chart1->Legends->Add(legend1);
			this->chart1->Location = System::Drawing::Point(288, 26);
			this->chart1->Name = L"chart1";
			series1->ChartArea = L"ChartArea1";
			series1->Legend = L"Legend1";
			series1->Name = L"Series1";
			this->chart1->Series->Add(series1);
			this->chart1->Size = System::Drawing::Size(348, 197);
			this->chart1->TabIndex = 1;
			this->chart1->Text = L"chart1";
			// 
			// PresentationButton
			// 
			this->PresentationButton->Location = System::Drawing::Point(93, 160);
			this->PresentationButton->Name = L"PresentationButton";
			this->PresentationButton->Size = System::Drawing::Size(75, 23);
			this->PresentationButton->TabIndex = 2;
			this->PresentationButton->Text = L"presentation";
			this->PresentationButton->UseVisualStyleBackColor = true;
			this->PresentationButton->Click += gcnew System::EventHandler(this, &Form1::PresentationButton_Click);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(690, 299);
			this->Controls->Add(this->PresentationButton);
			this->Controls->Add(this->chart1);
			this->Controls->Add(this->CalcButton);
			this->Name = L"Form1";
			this->Text = L"Form1";
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->chart1))->EndInit();
			this->ResumeLayout(false);

		}
#pragma endregion

		double** mydata;
		int currindex;

	private: System::Void CalcButton_Click(System::Object^  sender, System::EventArgs^  e) {
				 currindex = 0;

				 char* callString[] = {"very_cool_software", "10", "100", "0.1", "100"};
				 mydata = run(4, callString);
			 }

	private: System::Void PresentationButton_Click(System::Object^  sender, System::EventArgs^  e) {
				 
				 if (currindex < 100)
				 for (int i=0; i<5; i++)
				 {
					 chart1->Series[0]->Points->Clear();
					 for (int j=0; j<100; j++)
						 chart1->Series[0]->Points->AddXY(j* (10.0-0.0)/100, mydata[currindex][j]);
				 }

				 currindex++;

			 }


	};

	
}

